<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/5/27
 * Time: 17:43
 */

namespace Admin\Controller;


use Think\Controller;

class CustomController extends Controller {
    //客户列表搜索
    public function c_search(){
        $select = $_POST["select"];
        $ifin = $_POST["ifin"];
        if($ifin != ''){
        if (isset($ifin)) {
            $obj = M("user_main");
            if ($select == "phone") {
                $datas = $obj->where("phone like '" . $ifin."%'")->select();
            }elseif($select == "name"){
                $datas = $obj->where("name like '" . $ifin."%'")->select();
            }
            $this->assign('datas', $datas);

            if(isMobile()){
                $this->display("User/userList_m");
            }else{
                $this->display("User/userList");
            }
        }
        }else{
            if(isMobile()){
                $this->display("User/userList_m");
            }else{
                $this->display("User/userList");
            }
        }

    }
    //首页搜索
    public function first_search(){
        if(IS_POST){
            $data = I("post.");
            $obj = M("order_profile");
            $obj2 = M("user_main");
                if ($data["select"] == "phone") {

                        $datas = $obj2->query("SELECT * FROM user_main a LEFT JOIN order_main b ON a.uid=b.uid WHERE a.phone LIKE '" . $data["ifin"] . "%'");

                } elseif ($data["select"] == "name") {
                        $datas = $obj2->query("SELECT * FROM user_main a LEFT JOIN order_main b ON a.uid=b.uid WHERE a.name LIKE '" . $data["ifin"] . "%'");
                } elseif ($data["select"] == "ordernum") {
                        $datas = $obj2->query("SELECT * FROM user_main a LEFT JOIN order_main b ON a.uid=b.uid WHERE b.orderNum LIKE '" . $data["ifin"] . "%'");
                }
                $this->assign('datas', $datas);

                if(isMobile()){
                    $this->display("Order/orderList2_m");
                }else{
                    $this->display("Order/orderList2");
                }
        }else{
            $this->error("非法请求");
        }
    }
} 